#if !defined(TEST_INTERVALS_PER_CONTIG_H)
#define TEST_INTERVALS_PER_CONTIG_H


#include <string>
#include <vector>
#include <boost/tr1/unordered_map.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>

namespace test_intervals_per_contig
{
	
	struct t_interval
	{
		unsigned                    beg;
		unsigned                    end;
		t_interval(unsigned beg_, unsigned end_): beg(beg_), end(end_){}
	};
	inline bool operator <(const t_interval& me, const t_interval& other)
	{
		if (me.end == other.end)
			return me.beg < other.beg;
		return me.end < other.end;
	}

	typedef std::vector<t_interval> 							t_intervals;
	typedef std::vector<t_interval>::iterator 					i_intervals;

	typedef std::tr1::unordered_map<std::string, t_intervals > 	t_intervals_by_contig;
	typedef t_intervals_by_contig::iterator 					i_intervals_by_contig;
	
	//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
	// 
	//     t_test_intervals

	//			Uses open closed coordinates
	// 
	//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
	struct t_test_intervals
	{
									t_test_intervals(t_intervals_by_contig& intervals_by_contig_);
		t_intervals_by_contig& 		intervals_by_contig;
		t_interval					curr_interval;
		std::string     			curr_contig;
		i_intervals_by_contig		curr_contig_intervals;
		void						get_next_interval(unsigned test_pos);
		bool 						contains(const std::string& test_contig, unsigned test_pos);

	};

	namespace fs = boost::filesystem;
	void read_intervals(t_intervals_by_contig& intervals_by_contig, fs::ifstream& f_regions_to_retain);

};

#endif	// TEST_INTERVALS_PER_CONTIG_H
